﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable InconsistentNaming

namespace ChanTai.WebApi.Data
{
    /// <summary>
    /// 投保信息
    /// </summary>
    public class GroupInsureItem:ApiCovent
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int id { get; set; }
        /// <summary>
        /// 被保人姓名
        /// </summary>
        public string name { get; set; }

        /// <summary>
        /// 被保人身份证
        /// </summary>
        public string idno { get; set; }

        /// <summary>
        /// 职业类别
        /// </summary>
        public string zylb { get; set; }

        /// <summary>
        /// 主险保额
        /// </summary>
        public double acciBe { get; set; }

        /// <summary>
        /// 主险费率
        /// </summary>
        public double acciRoat { get; set; }

        private double minAcciRoat { get; set; }

        /// <summary>
        /// 主险费率设置
        /// </summary>
        /// <param name="item"></param>
        public void setAcciRoat(RoatItem item)
        {
            minAcciRoat = item.min;
            acciRoat = item.cur;
        }
        /// <summary>
        /// 主险保费
        /// </summary>
        public double acciBf { get; set; }

        /// <summary>
        /// 医疗保额
        /// </summary>
        public double medicalBe { get; set; }
        
        /// <summary>
        /// 医疗费率
        /// </summary>
        public double medicalRoat { get; set; }

        private double minMedicalRoat { get; set; }

        /// <summary>
        /// 主险费率设置
        /// </summary>
        /// <param name="item"></param>
        public void setMedicalRoat(RoatItem item)
        {
            minMedicalRoat = item.min;
            medicalRoat = item.cur;
        }

        /// <summary>
        /// 医疗保费
        /// </summary>
        public double medicalBf { get; set; }

        /// <summary>
        /// 住院津贴保额
        /// </summary>
        public double allowanceBe { get; set; }

        /// <summary>
        /// 住院津贴费率
        /// </summary>
        public double allowanceRoat { get; set; }
        
        private double minAallowanceRoat { get; set; }

        /// <summary>
        /// 主险费率设置
        /// </summary>
        /// <param name="item"></param>
        public void setAallowanceRoatRoat(RoatItem item)
        {
            minAallowanceRoat = item.min;
            allowanceRoat = item.cur;
        }

        /// <summary>
        /// 住院津贴保费
        /// </summary>
        public double allowanceBf { get; set; }

        /// <summary>
        /// 保费合计
        /// </summary>
        public double totalBf { get; set; }

        /// <summary>
        /// 保额合计
        /// </summary>
        public double totalBe { get; set; }

        /// <summary>
        /// 净费合计
        /// </summary>
        public double totalJf { get; set; }

        /// <summary>
        /// 计算保费
        /// </summary>
        public void calculat()
        {
            acciBf = Round(acciBe*acciRoat, 2);
            medicalBf = Round(medicalBe * medicalRoat, 2);
            allowanceBf = Round(allowanceBe * allowanceRoat, 2);
            totalBf = Round(acciBf + medicalBf + allowanceBf, 2);
            totalBe = Round(acciBe + allowanceBe + medicalBe, 2);
            var jacciBf = Round(acciBe * minAcciRoat, 2);
            var jmedicalBf = Round(medicalBe * minMedicalRoat, 2);
            var jallowanceBf = Round(allowanceBe * minAallowanceRoat, 2);
            totalJf = Round(jacciBf + jmedicalBf + jallowanceBf, 2);
        }
    }
}
